<template>
  <Head title="订单明细" isBack>
    <template #content>
      <Table
        ref="tableRef"
        :url="URL_PAGINGSTATIONTOTALREACORD"
        :columns="data.columns"
        :query="data.query"
        :toolbar="data.toolbar"
        :params="{ stationId, timeType, time }"
      ></Table>
    </template>
  </Head>
</template>

<script lang="ts" setup name="dividendOrderDetail">
import Head from '@/components/head/index.vue';
import Table from '@/components/table/index.vue';
import {
  URL_PAGINGSTATIONTOTALREACORD,
  EXPORT_STATIONTOTALREACORD,
} from '@/service/apis/financial';
import { exportFile } from '@/utils/utils';

const route = useRoute();
const {
  query: { stationId, timeType, time },
} = route;
// console.log(JSON.parse(stationId));
const tableRef = ref();

const data = reactive({
  columns: [
    {
      prop: 'orderId',
      label: '充电单号',
    },
    {
      prop: 'stationName',
      label: '电站名称',
    },
    {
      prop: 'connectorCode',
      label: '终端编码',
    },
    {
      prop: 'userOrgName',
      label: '用户归属企业',
    },
    {
      prop: 'createTime',
      label: '支付时间',
    },
    {
      prop: 'power',
      label: '充电度数',
    },
    {
      prop: 'powerAmount',
      label: '实收电费',
    },
    {
      prop: 'serviceAmount',
      label: '实收服务费',
    },
    {
      prop: 'channelShareAmount',
      label: '运营商分润',
    },
  ],
  query: [
    {
      label: '充电单号',
      prop: 'orderId',
      comName: 'input',
      props: {
        placeholder: '请输入充电单号',
      },
    },
    {
      label: '终端编码',
      prop: 'connectorCode',
      comName: 'input',
      props: {
        placeholder: '请输入终端编码',
      },
    },
  ],
  toolbar: [
    {
      label: '导出',
      permission: 'dividendSummaryList.export',
      icon: 'icon-export',
      type: 'primary',
      plain: true,
      handle: (row: any) => {
        const formData = Object.assign(tableRef.value?.getForm(), {
          stationId: stationId,
        });
        exportFile(
          EXPORT_STATIONTOTALREACORD,
          '分润汇总-电站-订单明细',
          formData
        );
      },
    },
  ],
});
</script>